package gui.event;

import gui.PlayersMap;
import gui.ToolContainer;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import dal.object.Tool;

public class ToolController extends MouseAdapter {
	private ToolContainer tools;
	
	public ToolController(ToolContainer tools){
		this.tools = tools;
	}
	
	/**
	 * controlls the Tool activation and rotation
	 */
	public void mousePressed(MouseEvent mouse) {			
		if(tools.isVisible()){
			if(mouse.getButton() == MouseEvent.BUTTON1){
				Tool tool = tools.useTool();
				
				if(tool != null){
					PlayersMap.ball.addTool(tool);
				}
			} else if(mouse.getButton() == MouseEvent.BUTTON3) {
				tools.rotate();
			}
		}
	}
}